<html>
<head>
<title>Save Book</title>
</head>
<body>
<?php

		//*** Update Record ***//
		$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
		$objDB = mysql_select_db("book_db");
		$strSQL=mysql_query("SET NAMES TIS620");
		$strSQL = "UPDATE books ";
		$strSQL .=" SET book_name = '".$_POST["book_name"]."', book_desc = '".$_POST["book_desc"]."',book_price = '".$_POST["book_price"]."',book_type = '".$_POST["book_type"]. "'  WHERE id = '".$_GET["id"]."' ";
		$objQuery = mysql_query($strSQL);		
	
	echo "Edit Complete<br>";
	echo "<meta http-equiv=refresh content=1;URL=booklist_data.php>";
	if($_FILES["picture"]["name"] != "")
	{
		if(move_uploaded_file($_FILES["picture"]["tmp_name"],"images/".$_FILES["picture"]["name"]))
		{

			//*** Delete Old File ***//			
			@unlink("images/".$_POST["hdnOldFile"]);
			
			//*** Update New File ***//
			$strSQL = "UPDATE books ";
			$strSQL .=" SET picture = '".$_FILES["picture"]["name"]."' WHERE book_code = '".$_GET["book_code"]."' ";
			$objQuery = mysql_query($strSQL);		

			echo "Upload Complete<br>";

		}
	
	}
?>

</body>
</html>